#编写一个函数ThreeNumberSum,接收数组array 和数字 targetsum,返回所有array里相加得targetsum的值。
def ThreeNumberSum(array,targetSum):

    array.sort()
    numbers = []

    for number in range(len(array)-2):
            
        left = number + 1
        right = len(array)-1

        while right < left:
            numberSum = array[left]+ array[right]+ array[number]

            if numberSum == targetSum:
                numbers.append(numberSum)
                left += 1
                right -= 1

            elif numberSum > targetSum:
                right -= 1

            elif numberSum < targetSum:
                left += 1

    return numbers
print(ThreeNumberSum([12, 3, 1, 2, -6, 5, -8, 6],0))